﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace AIthin.Model.Body
{
    public class Actuator
    {
        Wurm Parent;
        public int LengthMaximum { get; protected set; }
        public int LengthMinimum { get; protected set; }
        public int Length { get; protected set; }
        public int Position { get; set; }
        /// <summary>
        /// constructor
        /// </summary>
        /// <param name="length_max">maximum lengs for actuator</param>
        public Actuator(Wurm parent)
        {
            Parent = parent;
            Length = 16;
            LengthMaximum = Parent.reality.Width;
            LengthMinimum = 0;
            middle();

        }
        public void Draw(Graphics g)
        {
            g.FillRectangle(Brushes.Blue, Position, 2, Length, 6);
        }
        public void links()
        {
            if (Position > LengthMinimum) Position--;
            return;
        }
        public void rechts()
        {
            if (Position < LengthMaximum) Position++;
            return;
        }
        public void move(int shift)
        {
            Position += shift;
            if (Position > LengthMaximum) Position = LengthMaximum;
            if (Position < LengthMinimum) Position = LengthMinimum;
        }
        public void middle()
        {
            Position = LengthMaximum/2-Length/2;
        }
    }
}
